<script setup>
import { provideTableKey } from '../../../hooks/use-provide-key'

const { schema } = inject(provideTableKey)

const { field } = defineProps({
  field: Object,
})

const fieldName = field.field
const options = computed(() => field.dataSource?.data ?? [])

defineOptions({ name: 'RenderCheckbox' })
</script>

<template>
  <el-checkbox-group
    v-model="schema.data[fieldName]"
    v-bind="field.props"
  >
    <el-checkbox
      v-for="(item, index) in options"
      :key="index"
      :value="item.value"
      :label="item.label"
    >
      {{ item.label }}
    </el-checkbox>
  </el-checkbox-group>
</template>
